using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Stock.Dto;
using JTZY.Model.Stock;
using JTZY.Service.Stock.IStockService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-12-30
namespace JTZY.Admin.WebApi.Controllers.Stock
{
    /// <summary>
    /// 调仓订单货物明细
    /// </summary>
    [Verify]
    [Route("stock/Transferorderdetail")]
    public class TransferorderdetailController : BaseController
    {
        /// <summary>
        /// 调仓订单货物明细接口
        /// </summary>
        private readonly ITransferorderdetailService _TransferorderdetailService;

        public TransferorderdetailController(ITransferorderdetailService TransferorderdetailService)
        {
            _TransferorderdetailService = TransferorderdetailService;
        }

        /// <summary>
        /// 查询调仓订单货物明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "transferorderdetail:list")]
        public IActionResult QueryTransferorderdetail([FromQuery] TransferorderdetailQueryDto parm)
        {
            var response = _TransferorderdetailService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询调仓订单货物明细详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "transferorderdetail:query")]
        public IActionResult GetTransferorderdetail(long Id)
        {
            var response = _TransferorderdetailService.GetInfo(Id);
            
            var info = response.Adapt<TransferorderdetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加调仓订单货物明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "transferorderdetail:add")]
        [Log(Title = "调仓订单货物明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddTransferorderdetail([FromBody] TransferorderdetailDto parm)
        {
            var modal = parm.Adapt<Transferorderdetail>().ToCreate(HttpContext);

            var response = _TransferorderdetailService.AddTransferorderdetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新调仓订单货物明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "transferorderdetail:edit")]
        [Log(Title = "调仓订单货物明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateTransferorderdetail([FromBody] TransferorderdetailDto parm)
        {
            var modal = parm.Adapt<Transferorderdetail>().ToUpdate(HttpContext);
            var response = _TransferorderdetailService.UpdateTransferorderdetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除调仓订单货物明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "transferorderdetail:delete")]
        [Log(Title = "调仓订单货物明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteTransferorderdetail([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_TransferorderdetailService.Delete(idArr));
        }

    }
}